<?php
class CategoryIndexAction extends AdminAction
{
	public function __construct()
	{
		parent::__construct();
		$this->layout = 'default';
	}
	
	public function execute()
	{
		$categoryService = new CategoryService();
		
		$pid = $this->context->get('pid');
		if(!is_numeric($pid))
		{
			$pid = 0;
		}
		$this->data['pid'] = $pid;
		
		$this->data['categories']  = $categoryService->rows(array('pid'=>$pid), 'orderby DESC,id ASC');
		
		$this->data['menuCategories'] = $categoryService->getParentCategoryList($pid);
		
		if(count($this->data['menuCategories'])<=2)
		{
			$this->data['show_add'] = 1;
		}
		if(count($this->data['menuCategories'])<2)
		{
			$this->data['show_sub'] = 1;
		}
		
		$this->data['menu'] = 'category';
	}
}
